<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>選擇活動</title>
<meta name="layout" content="main" />
</head>
<body>
	<div class="body">
		<h1>選擇活動</h1>
		<g:if test="${flash.message}">
	        <div class="message">${flash.message}</div>
	    </g:if>
        <div class="list">
            <table>
                <thead>
                    <tr>
               	        <g:sortableColumn property="name" title="活動名稱" />
               	        <g:sortableColumn property="startAt" title="開始" />
               	        <g:sortableColumn property="endAt" title="結束" />
                    </tr>
                </thead>
                <tbody>
                <g:each in="${activityList}" status="i" var="activityInstance">
                    <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        <td>
                        	<g:if test="${type == 'register'}">
                        		<g:link action="register" params="[id:activityInstance.id]">${fieldValue(bean:activityInstance, field:'name')}</g:link>
                        	</g:if>
                        	<g:if test="${type == 'done'}">
                        		<g:link action="done" params="[id:activityInstance.id]">${fieldValue(bean:activityInstance, field:'name')}</g:link>
                        	</g:if>
                        </td>
                        <td>${fieldValue(bean:activityInstance, field:'startAt')}</td>
                        <td>${fieldValue(bean:activityInstance, field:'endAt')}</td>
                    </tr>
                </g:each>
                </tbody>
            </table>
        </div>
        <div class="paginateButtons">
            <g:paginate total="${activityTotal}" />
        </div>
    </div>
</body>
</html>